/*
 * MiniPOVEditor
 * by Andy Isaacson 10/5/2008
 * Written on a Sunday morning
 * 
 * For the MiniPOV kit - http://ladyada.net/make/minipov3/index.html
 */

import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;


public class MyMouseListener implements MouseListener {
	
	private static boolean mouseDown;
	private static boolean turnOn;

	public void mouseClicked(MouseEvent e) {}

	public void mouseEntered(MouseEvent e) {
		if (!mouseDown) return;
		
		Cell source;
		if (e.getSource() instanceof Cell)
			source = (Cell)e.getSource();
		else
			return;
		
		source.setOn(turnOn);
			
	}

	public void mouseExited(MouseEvent e) {}

	public void mousePressed(MouseEvent e) {
		Cell source;
		if (e.getSource() instanceof Cell)
			source = (Cell)e.getSource();
		else
			return;
			
		mouseDown = true;
		turnOn = !source.isOn();
		source.setOn(turnOn);
	}

	public void mouseReleased(MouseEvent e) {
		mouseDown = false;
	}

}
